﻿<%@ Page Title="" Language="VB" MasterPageFile="~/admin/AdminMaster.master" AutoEventWireup="false" CodeFile="AdminCategories.aspx.vb" Inherits="admin_AdminCategories" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" 
    Runat="Server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
    
    <div id="GridView">
    <asp:GridView ID="grvCategoriesView" runat="server" AllowPaging="True" CssClass="Gridview"
        AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="CategoryID" 
        DataSourceID="AccessDataSource1" >
        <Columns>
            <asp:BoundField DataField="CategoryID" HeaderText="ID" 
                InsertVisible="False" ReadOnly="True" SortExpression="CategoryID" >
            <ItemStyle HorizontalAlign="Center" />
            </asp:BoundField>
            <asp:BoundField DataField="CategoryName" HeaderText="Category Name" 
                SortExpression="CategoryName" />
            <asp:BoundField DataField="CategoryDesc" HeaderText="CategoryDesc" 
                SortExpression="CategoryDesc" />
            <asp:CheckBoxField DataField="IsVisible" HeaderText="Visible" 
                SortExpression="IsVisible" >
            <ItemStyle HorizontalAlign="Center" />
            </asp:CheckBoxField>
            <asp:CommandField CausesValidation="false" ShowEditButton="True">
            <ItemStyle HorizontalAlign="Center" />
            </asp:CommandField>
        </Columns>
        
    </asp:GridView>
    </div>
    <asp:AccessDataSource ID="AccessDataSource1" runat="server" 
        DataFile="~/App_Data/GotPink.accdb" 
        SelectCommand="SELECT * FROM [Category]" 
        DeleteCommand="DELETE FROM [Category] WHERE [CategoryID] = ?" 
        InsertCommand="INSERT INTO [Category] ([CategoryID], [CategoryName], [CategoryDesc], [IsVisible]) VALUES (?, ?, ?, ?)" 
        UpdateCommand="UPDATE [Category] SET [CategoryName] = ?, [CategoryDesc] = ?, [IsVisible] = ? WHERE [CategoryID] = ?">
        <DeleteParameters>
            <asp:Parameter Name="CategoryID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="CategoryID" Type="Int32" />
            <asp:Parameter Name="CategoryName" Type="String" />
            <asp:Parameter Name="CategoryDesc" Type="String" />
            <asp:Parameter Name="IsVisible" Type="Boolean" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="CategoryName" Type="String" />
            <asp:Parameter Name="CategoryDesc" Type="String" />
            <asp:Parameter Name="IsVisible" Type="Boolean" />
            <asp:Parameter Name="CategoryID" Type="Int32" />
        </UpdateParameters>
    </asp:AccessDataSource>
    <asp:Button ID="btnAddNew" runat="server" Text="Add New Category" 
        CssClass="btn" CausesValidation="False"/>
    
    
    <br />
    <asp:Panel ID="pnlAddNewCat" runat="server" Width="450px">
        <div class="ModalPopup">
            <br />
            <h2>Add New Category</h2>
            <table style="width: 400px; text-align:center" cellspacing="10">
                <tr>
                    <td>
                        <asp:RequiredFieldValidator ID="valCatName" runat="server" 
                            ControlToValidate="txtCatName" CssClass="validate" Display="Dynamic" 
                            ErrorMessage="Category name is required">*</asp:RequiredFieldValidator>
                        Category Name</td>
                    <td>
                        <asp:RequiredFieldValidator ID="valCatDesc" runat="server" 
                            ControlToValidate="txtCatDesc" CssClass="validate" Display="Dynamic" 
                            ErrorMessage="Description Required">*</asp:RequiredFieldValidator>
                        Category Desription</td>
                    <td>Is Visible</td>
                </tr>
                <tr>
                    <td><asp:TextBox ID="txtCatName" 
                            runat="server"></asp:TextBox></td>
                    <td><asp:TextBox ID="txtCatDesc" 
                            runat="server"></asp:TextBox></td>
                    <td><asp:CheckBox ID="chkIsVisible" runat="server" /></td>
                </tr>
               
                </table>
            <table style="width:400px; text-align: center" cellspacing="10">
                <tr>
                    <td>
                        <asp:Button ID="btnSubmit" runat="server" Text="Submit" cssclass="btn" 
                            Width="100px"/>
                        <asp:Button ID="btnCancel" runat="server" Text="Cancel" cssclass="btn" 
                            Width="100px" CausesValidation="False"/>
                    </td>
                </tr>
            </table>
            <table style="width:400px; text-align: center">
            <tr>
                <td>
                <asp:ValidationSummary ID="vldSummary" runat="server" CssClass="validate" 
                    DisplayMode="List" />
                    </td>
                    </tr>
            </table>
            <br />
            

        </div>
    </asp:Panel>
    <ajaxToolkit:ModalPopupExtender ID="ajaxModalPop" runat="server" PopupControlID="pnlAddNewCat" 
        TargetControlID="btnAddNew" BackgroundCssClass="ModalPopupBG" 
        CancelControlID="btnCancel">
    </ajaxToolkit:ModalPopupExtender>
    </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>


